﻿//===============================================================================
// Jammer.NET Development Library
// Jmr.Security
//===============================================================================
// Copyright © Junaid Fakhruddin, Matthew Leedham and Randolph Cabral.  
// All rights reserved.
//===============================================================================
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================

using Jmr.Entity.Poco;

namespace Jmr.Security
{

	/// <summary>
  /// Object Relational Mapping file for the "JmrSecurity" database.
	/// </summary>
	public partial class JmrSecurityMapping : Jmr.Entity.Poco.DatabaseMapper
	{
		/// <summary>
		/// JmrSecurityMapping constructor.
		/// </summary>
		public JmrSecurityMapping()
		{
      AddDatabaseMap<ApplicationRole>("JmrSecurity")
				.SetTableMap("reln_ApplicationRole")
				.AddTableColumnMap(e => e.Id, "approle_Id", true)
				.AddTableColumnMap(e => e.AppId, "app_Id")
				.AddTableColumnMap(e => e.RoleId, "role_Id")
				.SetSprocMap(CrudType.Select, "usp_ApplicationRole_Get")
				//.SetSprocMap(CrudType.Insert, "usp_ApplicationRole_Insert")
				//.SetSprocMap(CrudType.Update, "usp_ApplicationRole_Update")
				//.SetSprocMap(CrudType.Delete, "usp_ApplicationRole_Delete")
				.SetSprocMap(CrudType.SelectMany, "usp_ApplicationRole_GetAll")
				.SetSprocMap(CrudType.SelectMany, "usp_ApplicationRole_GetView", typeof(Role));

      AddDatabaseMap<UserRole>("JmrSecurity")
				.SetTableMap("reln_UserRole")
				.AddTableColumnMap(e => e.UserId, "user_Id")
				.AddTableColumnMap(e => e.RoleId, "role_Id")
				.AddTableColumnMap(e => e.RoleCode, "userrole_Code")
				.AddTableColumnMap(e => e.IsActive, "userrole_IsActive")
				.AddTableColumnMap(e => e.IsUdfmRoleAssignment, "userrole_IsUdfmRoleAssignment")
				.AddTableColumnMap(e => e.UserRoleId, "userrole_Id", true)
				.SetSprocMap(CrudType.Select, "usp_UserRole_Get")
				.SetSprocMap(CrudType.Insert, "usp_UserRole_Insert")
				.SetSprocMap(CrudType.Update, "usp_UserRole_Update")
				.SetSprocMap(CrudType.Delete, "usp_UserRole_Delete")
				.SetSprocMap(CrudType.SelectMany, "usp_RoleView_GetByUserId");

      AddDatabaseMap<Application>("JmrSecurity")
				.SetTableMap("tbl_Application")
				.AddTableColumnMap(e => e.Id, "app_Id", true)
				.AddTableColumnMap(e => e.Name, "app_Name")
				.AddTableColumnMap(e => e.Description, "app_Description")
				.SetSprocMap(CrudType.Select, "usp_Application_GetById")
				.SetSprocMap(CrudType.SelectMany, "usp_Application_GetAll")
				.SetSprocMap(CrudType.SelectMany, "usp_ApplicationView_GetByUserId", typeof(User));

      AddDatabaseMap<User>("JmrSecurity")
				.SetTableMap("tbl_User")
				.AddTableColumnMap(e => e.Id, "user_Id", true)
				.AddTableColumnMap(e => e.Domain, "user_Domain")
				.AddTableColumnMap(e => e.NtLogon, "user_NtLogon")
				.AddTableColumnMap(e => e.SID, "user_SID")
				.AddTableColumnMap(e => e.UserGuid, "user_Guid")
				.AddTableColumnMap(e => e.FirstName, "user_FName")
				.AddTableColumnMap(e => e.LastName, "user_LName")
				.AddTableColumnMap(e => e.FullName, "user_FullName")
				.AddTableColumnMap(e => e.Email, "user_Email")
				.AddTableColumnMap(e => e.Company, "user_Company")
				.AddTableColumnMap(e => e.Department, "user_Department")
				.AddTableColumnMap(e => e.Title, "user_Title")
				.AddTableColumnMap(e => e.IsActive, "user_IsActive")
				.AddTableColumnMap(e => e.IsDomainAccount, "user_IsDomainAccount")
				.AddTableColumnMap(e => e.CreateTimeStamp, "user_CreateTimeStamp")
				.AddTableColumnMap(e => e.ModifyTimeStamp, "user_ModifyTimeStamp")
				.AddTableColumnMap(e => e.USNChanged, "user_USNChanged")
				.AddTableColumnMap(e => e.EmpNo, "user_AmbEmpNo")
				.AddTableColumnMap(e => e.Region, "user_Region")
				.AddTableColumnMap(e => e.Division, "user_Division")
				.AddTableColumnMap(e => e.Description, "user_Description")
				.AddTableColumnMap(e => e.PhoneDirect, "user_PhoneDirect")
				.AddTableColumnMap(e => e.PhoneFax, "user_PhoneFax")
				.AddTableColumnMap(e => e.PhoneMobile, "user_PhoneMobile")
				.AddTableColumnMap(e => e.PhoneDirectOther, "user_PhoneDirectOther")
				.AddTableColumnMap(e => e.PhoneOther, "user_PhoneOther")
				.AddTableColumnMap(e => e.PhoneMobileOther, "user_PhoneMobileOther")
				.AddTableColumnMap(e => e.Address, "user_Address")
				.AddTableColumnMap(e => e.Location, "user_Location")
				.AddTableColumnMap(e => e.State, "user_State")
				.AddTableColumnMap(e => e.Country, "user_Country")
				.AddTableColumnMap(e => e.PostalCode, "user_PostalCode")
				.AddTableColumnMap(e => e.PhysicalOfficeCode, "user_PhysicalOfficeCode")
				//.AddRelationMap<Application>(CardinalityType.OneToMany, e => e.Applications, "usp_ApplicationView_GetByUserId")
				//.AddRelationMap<Role>(CardinalityType.OneToMany, e => e.Roles, "usp_RoleView_GetByUserId")
				.SetSprocMap(CrudType.Select, "usp_User_GetByNtLogon")
				.SetSprocMap(CrudType.SelectMany, "usp_UserView_GetAllActiveEmployees")
				.SetSprocMap(CrudType.SelectMany, "usp_User_GetAll", typeof(UserGetAllArgs));

			AddDatabaseMap<UserGetAllArgs>("JmrSecurity")
				.AddSyntheticColumnMap(e => e.IsActive, "user_IsActive");


			AddDatabaseMap<UserInsertUpdateTuple>("JmrSecurity")
				.AddSyntheticColumnMap(e => e.Domain, "Domain")
				.AddSyntheticColumnMap(e => e.NtLogon, "NtLogon")
				.AddSyntheticColumnMap(e => e.SID, "SID")
				.AddSyntheticColumnMap(e => e.Guid, "Guid")
				.AddSyntheticColumnMap(e => e.FirstName, "FName")
				.AddSyntheticColumnMap(e => e.LastName, "LName")
				.AddSyntheticColumnMap(e => e.FullName, "FullName")
				.AddSyntheticColumnMap(e => e.Email, "Email")
				.AddSyntheticColumnMap(e => e.Company, "Company")
				.AddSyntheticColumnMap(e => e.Department, "Department")
				.AddSyntheticColumnMap(e => e.Title, "Title")
				.AddSyntheticColumnMap(e => e.IsActive, "IsActive")
				.AddSyntheticColumnMap(e => e.IsDomainAccount, "IsDomainAccount")
				.AddSyntheticColumnMap(e => e.CreateTimeStamp, "CreateTimeStamp")
				.AddSyntheticColumnMap(e => e.ModifyTimeStamp, "ModifyTimeStamp")
				.AddSyntheticColumnMap(e => e.USNChanged, "USNChanged")
				.AddSyntheticColumnMap(e => e.EmpNo, "EmpNo")
				.AddSyntheticColumnMap(e => e.Region, "Region")
				.AddSyntheticColumnMap(e => e.Division, "Division")
				.AddSyntheticColumnMap(e => e.Description, "Description")
				.AddSyntheticColumnMap(e => e.PhoneDirect, "PhoneDirect")
				.AddSyntheticColumnMap(e => e.PhoneFax, "PhoneFax")
				.AddSyntheticColumnMap(e => e.PhoneMobile, "PhoneMobile")
				.AddSyntheticColumnMap(e => e.PhoneDirectOther, "PhoneDirectOther")
				.AddSyntheticColumnMap(e => e.PhoneOther, "PhoneOther")
				.AddSyntheticColumnMap(e => e.PhoneMobileOther, "PhoneMobileOther")
				.AddSyntheticColumnMap(e => e.Address, "Address")
				.AddSyntheticColumnMap(e => e.Location, "Location")
				.AddSyntheticColumnMap(e => e.State, "State")
				.AddSyntheticColumnMap(e => e.Country, "Country")
				.AddSyntheticColumnMap(e => e.PostalCode, "PostalCode")
				.AddSyntheticColumnMap(e => e.PhysicalOfficeCode, "PhysicalOfficeCode")
				.SetSprocMap(CrudType.Insert, "usp_User_InsertUpdate");


      AddDatabaseMap<Role>("JmrSecurity")
				.SetTableMap("tbl_Role")
				.AddTableColumnMap(e => e.Id, "role_Id", true)
				.AddTableColumnMap(e => e.Name, "role_Name")
				.AddTableColumnMap(e => e.Description, "role_Description")
				.AddTableColumnMap(e => e.IsCodeRequired, "role_IsCodeRequired")
				.AddTableColumnMap(e => e.CodeMaskRegEx, "role_CodeMaskRegEx")
				.AddTableColumnMap(e => e.IsManaged, "role_IsManaged")
				.AddTableColumnMap(e => e.ExtRoleId, "ext_RoleId")
				.AddTableColumnMap(e => e.ExtId, "ext_Id")
				.SetSprocMap(CrudType.Select, "usp_Role_GetByRoleId")
				.SetSprocMap(CrudType.Insert, "usp_Role_Insert")
				.SetSprocMap(CrudType.Update, "usp_Role_Update")
				.SetSprocMap(CrudType.Delete, "usp_Role_Delete")
				.SetSprocMap(CrudType.SelectMany, "usp_Role_GetAll");

      AddDatabaseMap<UserRoleView>("JmrSecurity")
				.AddSyntheticColumnMap(e => e.RoleId, "role_Id")
				.AddSyntheticColumnMap(e => e.RoleName, "role_Name")
				.AddSyntheticColumnMap(e => e.RoleDescription, "role_Description")
				.AddSyntheticColumnMap(e => e.RoleIsCodeRequired, "role_IsCodeRequired")
				.AddSyntheticColumnMap(e => e.RoleCodeMaskRegEx, "role_CodeMaskRegEx")
				.AddSyntheticColumnMap(e => e.RoleIsManaged, "role_IsManaged")
				.AddSyntheticColumnMap(e => e.ExtRoleId, "ext_RoleId")
				.AddSyntheticColumnMap(e => e.ExtId, "ext_Id")
				.AddSyntheticColumnMap(e => e.UserId, "user_Id")
				//.AddSyntheticColumnMap(e => e.RoleId1, "role_Id1")
				.AddSyntheticColumnMap(e => e.UserroleCode, "userrole_Code")
				.AddSyntheticColumnMap(e => e.UserroleIsActive, "userrole_IsActive")
				.AddSyntheticColumnMap(e => e.UserroleIsUdfmRoleAssignment, "userrole_IsUdfmRoleAssignment")
				.AddSyntheticColumnMap(e => e.UserroleId, "userrole_Id")
				.AddSyntheticColumnMap(e => e.UserFullName, "user_FullName")
				.AddSyntheticColumnMap(e => e.UserDomain, "user_Domain")
				//.AddSyntheticColumnMap(e => e.SourceUser, "SourceUser")
				.SetSprocMap(CrudType.SelectMany, "usp_RoleView_GetAll")
				.SetSprocMap(CrudType.SelectMany, "usp_RoleView_GetByUserId", typeof(UserRoleViewArgs));

      AddDatabaseMap<UserRoleViewArgs>("JmrSecurity")
				.AddSyntheticColumnMap(e => e.UserId, "user_Id");
		}
	}

}
